
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Upgrading Django to a newer version &#8212; Django 1.11.22.dev20190603194737 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Error reporting" href="error-reporting.html" />
    <link rel="prev" title="Deployment checklist" href="deployment/checklist.html" />



 
<script type="text/javascript" src="../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 1.11.22.dev20190603194737 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../index.html">Home</a>  |
        <a title="Table of contents" href="../contents.html">Table of contents</a>  |
        <a title="Global index" href="../genindex.html">Index</a>  |
        <a title="Module index" href="../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="deployment/checklist.html" title="Deployment checklist">previous</a>
     |
    <a href="index.html" title="“How-to” guides" accesskey="U">up</a>
   |
    <a href="error-reporting.html" title="Error reporting">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="howto-upgrade-version">
            
  <div class="section" id="s-upgrading-django-to-a-newer-version">
<span id="upgrading-django-to-a-newer-version"></span><h1>Upgrading Django to a newer version<a class="headerlink" href="#upgrading-django-to-a-newer-version" title="Permalink to this headline">¶</a></h1>
<p>While it can be a complex process at times, upgrading to the latest Django
version has several benefits:</p>
<ul class="simple">
<li>New features and improvements are added.</li>
<li>Bugs are fixed.</li>
<li>Older version of Django will eventually no longer receive security updates.
(see <a class="reference internal" href="../internals/release-process.html#backwards-compatibility-policy"><span class="std std-ref">Supported versions</span></a>).</li>
<li>Upgrading as each new Django release is available makes future upgrades less
painful by keeping your code base up to date.</li>
</ul>
<p>Here are some things to consider to help make your upgrade process as smooth as
possible.</p>
<div class="section" id="s-required-reading">
<span id="required-reading"></span><h2>Required Reading<a class="headerlink" href="#required-reading" title="Permalink to this headline">¶</a></h2>
<p>If it’s your first time doing an upgrade, it is useful to read the <a class="reference internal" href="../internals/release-process.html"><span class="doc">guide
on the different release processes</span></a>.</p>
<p>Afterwards, you should familiarize yourself with the changes that were made in
the new Django version(s):</p>
<ul class="simple">
<li>Read the <a class="reference internal" href="../releases/index.html"><span class="doc">release notes</span></a> for each ‘final’ release from
the one after your current Django version, up to and including the version to
which you plan to upgrade.</li>
<li>Look at the <a class="reference internal" href="../internals/deprecation.html"><span class="doc">deprecation timeline</span></a> for the
relevant versions.</li>
</ul>
<p>Pay particular attention to backwards incompatible changes to get a clear idea
of what will be needed for a successful upgrade.</p>
<p>If you’re upgrading through more than one feature version (e.g. A.B to A.B+2),
it’s usually easier to upgrade through each feature release incrementally
(A.B to A.B+1 to A.B+2) rather than to make all the changes for each feature
release at once. For each feature release, use the latest patch release (A.B.C).</p>
<p>The same incremental upgrade approach is recommended when upgrading from one
LTS to the next.</p>
</div>
<div class="section" id="s-dependencies">
<span id="dependencies"></span><h2>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline">¶</a></h2>
<p>In most cases it will be necessary to upgrade to the latest version of your
Django-related dependencies as well. If the Django version was recently
released or if some of your dependencies are not well-maintained, some of your
dependencies may not yet support the new Django version. In these cases you may
have to wait until new versions of your dependencies are released.</p>
</div>
<div class="section" id="s-resolving-deprecation-warnings">
<span id="resolving-deprecation-warnings"></span><h2>Resolving deprecation warnings<a class="headerlink" href="#resolving-deprecation-warnings" title="Permalink to this headline">¶</a></h2>
<p>Before upgrading, it’s a good idea to resolve any deprecation warnings raised
by your project while using your current version of Django. Fixing these
warnings before upgrading ensures that you’re informed about areas of the code
that need altering.</p>
<p>In Python, deprecation warnings are silenced by default. You must turn them on
using the <code class="docutils literal notranslate"><span class="pre">-Wall</span></code> Python command line option or the <span class="target" id="index-0"></span><a class="reference external" href="https://docs.python.org/3/using/cmdline.html#envvar-PYTHONWARNINGS" title="(in Python v3.7)"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONWARNINGS</span></code></a>
environment variable. For example, to show warnings while running tests:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> python -Wall manage.py <span class="nb">test</span>
</pre></div>
</div>
<p>If you’re not using the Django test runner, you may need to also ensure that
any console output is not captured which would hide deprecation warnings. For
example, if you use <cite>py.test</cite>:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> <span class="nv">PYTHONWARNINGS</span><span class="o">=</span>all py.test tests --capture<span class="o">=</span>no
</pre></div>
</div>
<p>Resolve any deprecation warnings with your current version of Django before
continuing the upgrade process.</p>
<p>Third party applications might use deprecated APIs in order to support multiple
versions of Django, so deprecation warnings in packages you’ve installed don’t
necessarily indicate a problem. If a package doesn’t support the latest version
of Django, consider raising an issue or sending a pull request for it.</p>
</div>
<div class="section" id="s-installation">
<span id="installation"></span><h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
<p>Once you’re ready, it is time to <a class="reference internal" href="../topics/install.html"><span class="doc">install the new Django version</span></a>. If you are using <a class="reference external" href="https://virtualenv.pypa.io/">virtualenv</a> and it is a major upgrade, you
might want to set up a new environment with all the dependencies first.</p>
<p>Exactly which steps you will need to take depends on your installation process.
The most convenient way is to use <a class="reference external" href="https://pip.pypa.io/">pip</a> with the <code class="docutils literal notranslate"><span class="pre">--upgrade</span></code> or <code class="docutils literal notranslate"><span class="pre">-U</span></code> flag:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> pip install -U Django
</pre></div>
</div>
<p><a class="reference external" href="https://pip.pypa.io/">pip</a> also automatically uninstalls the previous version of Django.</p>
<p>If you use some other installation process, you might have to manually
<a class="reference internal" href="../topics/install.html#removing-old-versions-of-django"><span class="std std-ref">uninstall the old Django version</span></a> and
should look at the complete installation instructions.</p>
</div>
<div class="section" id="s-testing">
<span id="testing"></span><h2>Testing<a class="headerlink" href="#testing" title="Permalink to this headline">¶</a></h2>
<p>When the new environment is set up, <a class="reference internal" href="../topics/testing/overview.html"><span class="doc">run the full test suite</span></a> for your application. Again, it’s useful to turn
on deprecation warnings on so they’re shown in the test output (you can also
use the flag if you test your app manually using <code class="docutils literal notranslate"><span class="pre">manage.py</span> <span class="pre">runserver</span></code>):</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> python -Wall manage.py <span class="nb">test</span>
</pre></div>
</div>
<p>After you have run the tests, fix any failures. While you have the release
notes fresh in your mind, it may also be a good time to take advantage of new
features in Django by refactoring your code to eliminate any deprecation
warnings.</p>
</div>
<div class="section" id="s-deployment">
<span id="deployment"></span><h2>Deployment<a class="headerlink" href="#deployment" title="Permalink to this headline">¶</a></h2>
<p>When you are sufficiently confident your app works with the new version of
Django, you’re ready to go ahead and <a class="reference internal" href="deployment/index.html"><span class="doc">deploy</span></a>
your upgraded Django project.</p>
<p>If you are using caching provided by Django, you should consider clearing your
cache after upgrading. Otherwise you may run into problems, for example, if you
are caching pickled objects as these objects are not guaranteed to be
pickle-compatible across Django versions. A past instance of incompatibility
was caching pickled <a class="reference internal" href="../ref/request-response.html#django.http.HttpResponse" title="django.http.HttpResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">HttpResponse</span></code></a> objects, either
directly or indirectly via the <a class="reference internal" href="../topics/cache.html#django.views.decorators.cache.cache_page" title="django.views.decorators.cache.cache_page"><code class="xref py py-func docutils literal notranslate"><span class="pre">cache_page()</span></code></a>
decorator.</p>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Upgrading Django to a newer version</a><ul>
<li><a class="reference internal" href="#required-reading">Required Reading</a></li>
<li><a class="reference internal" href="#dependencies">Dependencies</a></li>
<li><a class="reference internal" href="#resolving-deprecation-warnings">Resolving deprecation warnings</a></li>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#testing">Testing</a></li>
<li><a class="reference internal" href="#deployment">Deployment</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="deployment/checklist.html"
                        title="previous chapter">Deployment checklist</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="error-reporting.html"
                        title="next chapter">Error reporting</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/howto/upgrade-version.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Jun 03, 2019</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="deployment/checklist.html" title="Deployment checklist">previous</a>
     |
    <a href="index.html" title="“How-to” guides" accesskey="U">up</a>
   |
    <a href="error-reporting.html" title="Error reporting">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>